package cn.wolfcode.crm.query;

import cn.wolfcode.crm.util.DateUtil;
import com.sun.org.apache.bcel.internal.generic.RETURN;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.stereotype.Service;

import java.util.Date;

@Setter
@Getter
@ToString
public class CustomerReportQueryObject extends QueryObject {

    private String keyword;

    private String key;
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    private Date beginDate;

    @DateTimeFormat(pattern = "yyyy-MM-dd")
    private Date endDate;

    public Date getendDate() {//一天最后日期23.59.59
        Date endDate = DateUtil.getEndDate(this.endDate);
        return endDate;
    }

    private String groupCondition = "e.name";//分组查询条件

    public Object getGroupType() {
        String groupTypeName;
        if ("e.name".equals(groupCondition)) {
            return groupTypeName = "员工";
        } else if("DATE_FORMAT(c.input_time, '%Y')".equals(groupCondition)) {
            return groupTypeName = "年";

        }else if("DATE_FORMAT(c.input_time, '%Y-%m')".equals(groupCondition)) {
            return groupTypeName = "月";
        }else{
            return groupTypeName = "日";
        }
    }
}
